package cn.tedu.egmvc6.base.response;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
public class JsonResult {
    private Integer state;
    private String message;
    private Object data;

    public JsonResult(StateCode stateCode) {
        this.state=stateCode.getState();
        this.message=stateCode.getMessage();
    }
    public JsonResult(StateCode stateCode,Object data) {
        this.state=stateCode.getState();
        this.message=stateCode.getMessage();
        this.data=data;
    }

    public static JsonResult ok(){
        return new JsonResult(StateCode.OPERATION_SUCCESS);
    }
    public static JsonResult ok(Object data){
        return new JsonResult(StateCode.OPERATION_SUCCESS,data);
    }
}
